/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.agilelang.editor.listener;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
import org.agilelang.db.toagile.DlgDataBase;
import org.agilelang.editor.ViewFrame;

/**
 *
 * @author RODERICK
 */
public class DBtoAgileLang implements ActionListener {

    ViewFrame frame;

    public DBtoAgileLang(ViewFrame frame) {
        this.frame = frame;
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if (frame.getPathProject().equals("")) {
            JOptionPane.showMessageDialog(null, "Create a new Project",
                    "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }


        DlgDataBase dialog = new DlgDataBase(new javax.swing.JFrame(), true);
        dialog.setLocationRelativeTo(null);
        dialog.setVisible(true);
        if (dialog.isStatus()) {
            frame.createFile("def.agile", dialog.getFile_def());
            frame.createFile("model.agile", dialog.getFile_model());
            frame.createFile("controller.agile", dialog.getFile_controller());
            frame.createFile("menu.agile", dialog.getFile_menu());
        }
    }
}
